<?php

namespace App\Http\Controllers\Wechat;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Buildings;

class BuildController extends BaseController
{
    public function index(){
        return view('wechat.build.index');
    }

    public function load(Request $request){
        $data['success']=false;
        if($request->ajax()){
            $build = Buildings::with(array('attach'=>function($query){
                $query->select('id','path');
            }))->where('valid','=',1)->orderByRaw('RAND()')->get();
            $data['success']=true;
            $data['build']=$build;
        }
        return response()->json($data);
    }
}
